class Solution(object):
    def reverseStr(self, s, k):
        """
        :type s: str
        :type k: int
        :rtype: str
        """
        s = list(s)
        for i in range(0, len(s), 2 * k):
            s[i:i+k] = reversed(s[i:i+k]) # 得到一个迭代器
        return ''.join(s)
if __name__ == '__main__':
    s = "abcdefg"
    k = 2
    print(Solution().reverseStr(s, k))